//
//  ViewController.m
//  AppControllerDevices
//
//  Created by joker on 15/7/30.
//  Copyright (c) 2015年 joker. All rights reserved.
//

#import "ViewController.h"

#import "IOTCAPIs.h"
#import "AVAPIs.h"
#import "AVIOCTRLDEFs.h"
#import "AVFRAMEINFO.h"

@interface ViewController ()

@end

@implementation ViewController

-(void)updateView:(UIImage*)newImage{
    NSLog(@"显示新画面");
    [self.VideoImageView setImage: newImage];
}
- (IBAction)ConnectDevice:(UIButton *)sender {
    self.client = [[iCamerClient alloc] init];
    self.client.delegate = self;
    
    [self.client ConnectDeviceWithUID:self.DeviceUID.text UserName:self.UserName.text PassWord:self.Password.text];
}
- (IBAction)cancelConnect:(UIButton *)sender {
    [self.client CancelConnectDevice];
}
- (IBAction)commands:(UIButton *)sender {
    
    NSLog(@"Button Tag is: %lu", (long)sender.tag);
    
    switch (sender.tag) {
        case 1:
            [self.client Video_Start];
            break;
        case 2:
            [self.client Video_Stop];
            break;
        case 3:
            [self.client Audio_Start];
            break;
        case 4:
            [self.client Audio_Stop];
            break;
        case 5:
            [self.client LED_On];
            break;
        case 6:
            [self.client LED_Off];
            break;
        case 7:
            [self.client Alarm_On];
            break;
        case 8:
            [self.client Alarm_Off];
            break;
        case 9:
             [self.client SetPTZMotionWithCommand:AVIOCTRL_PTZ_UP];
            break;
        case 10:
            [self.client SetPTZMotionWithCommand:AVIOCTRL_PTZ_DOWN];
            break;
        case 11:
             [self.client SetPTZMotionWithCommand:AVIOCTRL_PTZ_LEFT];
            break;
        case 12:
             [self.client SetPTZMotionWithCommand:AVIOCTRL_PTZ_RIGHT];
            break;
        case 13:
            [self.client SetStreamQuality:AVIOCTRL_QUALITY_LOW];
            break;
        case 14:
            [self.client SetStreamQuality:AVIOCTRL_QUALITY_MIDDLE];
            break;
        case 15:
            [self.client SetStreamQuality:AVIOCTRL_QUALITY_HIGH];
            break;
        case 16:
            [self.client SetAudioFormat:MEDIA_CODEC_AUDIO_PCM];
            break;
        case 17:
            [self.client SetAudioFormat:MEDIA_CODEC_AUDIO_G711A];
            break;
        case 18:
            [self.client SetAudioFormat:MEDIA_CODEC_AUDIO_AAC];
            break;
        default:
            NSLog(@"未知控制命令");
            break;
    }
}

@end
